 package com.yh.spring.mybatis.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yh.spring.mybatis.dao.OrderMapper;
import com.yh.spring.mybatis.model.Order;
import com.yh.spring.mybatis.model.Page;
import com.yh.spring.mybatis.service.IOrderService;
@Service("IOrderService")
public class OrderServiceImpl implements IOrderService{
	@Autowired
	private OrderMapper orderMapper;
	
	@Override
	public Order getOrder(Order order) {
		return orderMapper.getOrder(order);
	}
	@Override
	public void addOrder(Order order) {
		orderMapper.addOrder(order);
	}
	@Override
	public void delOrder(Order order) {
		orderMapper.delOrder(order);
	}
	@Override
	public void editOrder(Order order) {
		orderMapper.editOrder(order);
	}
	@Override
	public Page queryOrder(Map<String, Object> cond) {
		Page page=new Page();
		page.setTotalNum(orderMapper.getOrderCount(cond));
		int pageSize=Integer.parseInt(String.valueOf(cond.get("pageSize")));
		int curPageNum=Integer.parseInt(String.valueOf(cond.get("pageNum")));
		page.setCurPageNum(curPageNum);
		page.setTotalPage(page.getTotalNum()/pageSize+(page.getTotalNum()%pageSize==0?0:1));
		page.setResult(orderMapper.getLikeOrder(cond));
		return page;
	}
}
